﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>标题栏显示时间</title>
    <script type="text/javascript">
        var clocktext;
        var pagetitle = document.title; // 获取页面标题
        function viewTime(){
            today = new Date();
            sec = today.getSeconds();
            hr = today.getHours();
            min = today.getMinutes();
            if(hr<=9)
                hr = "0" + hr;
            if(min<=9)
                min = "0" + min;
            if(sec<=9)
                sec = "0" + sec;
            var clocktext ="当前时间是：" + hr + ":" + min + ":" + sec;
            // 间隔1000毫秒实现时间的更新
            clocktimer = setTimeout("viewTime()",1000);
            document.title = pagetitle + clocktext; // 更新显示标题
        }
        if(document.all)
            viewTime();
    </script>
</head>
<body>

</body>
</html>